package org.base.admin.utils.web;

import org.base.admin.config.security.JwtUser;
import org.base.admin.config.security.JwtUserFactory;
import org.base.dao.modules.sys.model.SysUserDO;
import org.springframework.security.core.context.SecurityContextHolder;

public final class  WebSecurityUtils {
	
	public static SysUserDO getUser() {
		JwtUser user = (JwtUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		return JwtUserFactory.createSysUser(user);
	}
	
	public static Long getUserId() {
		JwtUser user = (JwtUser)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		return user.getId();
	}

}
